package com.imti.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imti.entity.DeskWork;
import com.imti.entity.dto.DeskWorkDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (DeskWork)表数据库访问层
 *
 * @author makejava
 * @since 2023-02-01 12:13:29
 */

@Mapper
public interface DeskWorkDao extends BaseMapper<DeskWork> {


    /*@Select("select hosp_id,desk_name,desk_intro,desk_address,desk_tel from desk_work where desk_name LIKE concat ('%',#{desk_name},'%')")
    public DeskWork findAllDeskWorkByName(String deskName);

    @Select("SELECT ds.dep_sys_name,dw.desk_name FROM desk_work dw LEFT JOIN dep_sys ds ON ds.dep_sys_id=dw.dep_sys_id WHERE dw.desk_name LIKE concat ('%',#{deskName},'%') ")
    public List<DeskWork> findDeskWorkByName(String deskName);*/

    @Select("<script>"+
            "select desk_name,desk_id,dep_sys_id from desk_work where dep_sys_id = #{depSysId}"+
                    "<if test='searchName!=null and searchName!=\"\"'>"+
                    " and desk_name like concat('%',#{searchName},'%')"+
                    "</if>"+
            "</script>")
    public List<DeskWork> ByDeskId(int depSysId,String searchName);

    @Select("SELECT ho.hos_name,dw.`desk_name`,dw.`desk_intro`\n" +
            "FROM hospital ho,desk_work dw\n" +
            "WHERE ho.hosp_id=dw.`hosp_id`\n" +
            "AND dw.`desk_id`=#{desk_id}")
    public List<DeskWorkDto> findDeskWorkById(Integer deskId);

    @Select("select desk_name,desk_id from desk_work")
    public List<DeskWork> findAllDeskWork();


}

